<?php
/**
 *考勤报告
 */
apf_require_class('Oa_Test_AbstractTest');
apf_require_class('Bll_Attendance_DailyLeave');
class Oa_Test_Attendance_ReportTest extends Oa_Test_AbstractTest {
    public function setUp(){
    }
    public function tearDown(){

    }
    /**
     * 打卡记录
     * @dataProvider data_user_day_status
     */
    public function testMonthReport($params,$result){
        $daily = new Bll_Attendance_DailyLeave();
        $yearmonth = $params['yearmonth'];

        $month_bll = new Bll_Attendance_MonthSpecialSet();
        $month_set = $month_bll->get_month_special_set($yearmonth);
        $month_set_day = $month_set['settlement'];#得到这个月的结算日

        $curr_unix =strtotime($yearmonth.'01');
        $prev_start = $curr_unix-10;
        //$prev_start = mktime(0,0,0,$month-1,1,$year);
        //取上个月的结算日
        $prev_yearmonth = date('Ym',$prev_start);
        $prev_start = $prev_yearmonth.'01';
        $prev_end = $prev_yearmonth.date('t',strtotime($prev_start));
        $month_set_prev = $month_bll->get_month_special_set($prev_yearmonth);
        $prev_date = $month_set_prev['settlement'];#得到上个月的结算日

        $key1 = $params['uid'].'-'.$params['start'].'-'.$month_set_day.'-before';
        $key2 = $params['uid'].'-'.$month_set_day.'-'.$prev_start.'-after';
        $key3 = $params['uid'].'-'.$prev_start.'-'.$prev_end.'-last';//0901 0930上月未清，

        $daily->set_before_settlement_data($key1,$params['first']);
        $daily->set_after_settlement_data($key2,$params['two']);
        $daily->set_last_settlement_data($key3,$params['three']);

        $data = $daily->get_report_data($params['uid'],$params['start'],$params['end']);

        $data['oa_prexj_info'] = $data['oa_prexj_info_debug'];
        unset($data['meal']);
        unset($data['oa_url']);
        unset($data['debug_info']);
        unset($data['debug']);
        unset($data['oa_prexj_info_debug']);
        $this->assertEquals($data,$result);
    }


    public function data_user_record(){

    }

    public function data_user_day_status(){
        $uid=4555;
        $yearmonth = 201210;
        $start_n=$yearmonth.'01';
        $start = strtotime($start_n);
        $end_n=$yearmonth.date('t',$start);
        $end=strtotime($end_n);
        $day_list = array();
        for($i=$start;$i<=$end;$i+=86400){
            $day = date('Ymd',$i);
            $day_list[$day] = array(
                    'user_id'        => $uid,
                    'dateline'       => $day,
                    'days'           => 0,
                    'am_status'      => 5,
                    'am_type'        => 0,
                    'am_leave_status'=> 0,
                    'pm_status'      => 6,
                    'pm_type'        => 0,
                    'pm_leave_status'=> 0,
                    'is_later'       => 0,
                    'leave_early'    => 0,
            );
        }
        $day_list[20121031] = array(
                'user_id'=>$uid,'days'=>'0.5','dateline'=>20121031,'am_status'=>5,'am_type'=>7,'am_leave_status'=>2,'pm_status'=>6,'pm_type'=>0,'pm_leave_status'=>0
                        );

        $day_after=array();
        $day_last[20120926] = array(
                'user_id'=>$uid,'dateline'=>20120926,'leave_type'=>6,'leave_status'=>2,'leave_apm'=>1
                );
        //$day_last=array();
        return array(
                array(
                        array(
                                'uid'=>$uid,
                                'start'=>$start_n,
                                'end'=>$end_n,
                                'yearmonth'=>$yearmonth,
                                'first'=>$day_list,
                                'two'=>$day_after,
                                'three'=>$day_last),
                        array(
                                'work_att_day' => 21,
                                'rice_day' => 20,
                                'oa_kg' => 0,
                                'oa_cd' => 0,
                                'oa_gc' => 0,
                                'oa_gc_passed' => 0,
                                'oa_cc' => 0,
                                'oa_cc_passed' => 0,
                                'oa_sj' => 0,
                                'oa_sj_passed' => 0,
                                'oa_bj' => 0,
                                'oa_bj_passed' => 0,
                                'oa_nj' => 0.5,
                                'oa_nj_passed' => 0.5,
                                'oa_oj' => 0,
                                'oa_oj_passed' => 0,
                                'other_more' => Array(),
                                'oa_prexj' => Array(
                                    '病假' => -0.5
                                ),
                                'oa_prexj_info' => Array(
                                    '20120926' => array(6=>-0.5)
                                ),
                                'work_act_day' => 21,
                                'work_act_not_day' => 0),
                        "正常"),//first test data
        );
    }

}